package com.whsm.boot.configraurtion;

import com.whsm.boot.bean.Car;
import com.whsm.boot.bean.Pet;
import com.whsm.boot.bean.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;


@Configuration(proxyBeanMethods = false)
//@ConditionalOnBean(name = "tom")
@ImportResource("classpath:applicationcontext.xml")
@EnableConfigurationProperties(Car.class)
public class MyConfig {
    @Bean("user")
    public User getUser(){
        User zhangsan = new User("zhangsan ",15);
        zhangsan.setPet(getPet());
        return zhangsan;
    }
    @Bean("pet")
    public Pet getPet(){
        Pet pet = new Pet();
        pet.setName("tom");
        return pet;
    }
}
